<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/layui/css/layui.css">
    <link rel="icon" href="${pageContext.request.contextPath}/assets/images/favicon.png" type="image/png">
    <title>商品类型</title>


    <link href="${pageContext.request.contextPath}/assets/plugins/morris-chart/morris.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet"/>

    <link href="${pageContext.request.contextPath}/assets/css/icons.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/responsive.css" rel="stylesheet">


</head>
<body class="sticky-header">
<jsp:include page="../inc/left.jsp"/>
<div class="main-content" >
    <jsp:include page="../inc/header.jsp"/>
    <div class="wrapper">

        <div class="page-title-box">
            <h4 class="page-title">商品类型</h4>
            <ol class="breadcrumb">
                <li>
                    <a href="${pageContext.request.contextPath}/index">首页</a>
                </li>
                <li>
                    <a href="#">商品</a>
                </li>
                <li class="active">
                    商品类型
                </li>
            </ol>
            <div class="clearfix"></div>
        </div>
        <br>
        <div data-v-2adcf524="" class="header-title" style="background-color: white;height: 50px;line-height: 50px">
            <div class="el-card__body"><i data-v-2adcf524="" class="el-icon-tickets" style="margin-top: 5px;"></i> <span
                    data-v-2adcf524="" style="margin-left: 20px;line-height: 50px">数据列表</span>
                <button type="button" class="btn btn-info" onclick="addList()"
                        style="margin-left: 90%;margin-top: -40px;outline: none">添加
                </button>
            </div>
        </div>


        <div class="row">
            <div class="col-md-12">
                <div class="white-box">
                    <div class="table-responsive">
                        <table id="example" class="table" style="text-align: center">
                            <thead>
                            <tr>
                                <th style="text-align: center">编号</th>
                                <th style="text-align: center">类型名称</th>
                                <th style="text-align: center">属性数量</th>
                                <th style="text-align: center">参数数量</th>
                                <th style="text-align: center">设置</th>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${productAttributeList2.list}" var="p">
                                <tr>
                                    <td>${p.id}</td>
                                    <td>${p.name}</td>
                                    <td>${p.attributeCount}</td>
                                    <td>${p.paramCount}</td>
                                    <td class="el-table_18_column_134 is-center ">
                                        <div class="cell">
                                            <button data-v-2adcf524="" type="button"
                                                    class="btn btn-success">
                                                <a style="color: white;outline: none"
                                                   href="${pageContext.request.contextPath}/goods/attributeList?id=${p.id}&type=0&page=1">属性列表</a>
                                            </button>
                                            <button data-v-2adcf524="" type="button"
                                                    class="btn btn-success">
                                                <a style="color: white;outline: none"
                                                   href="${pageContext.request.contextPath}/goods/attributeList?id=${p.id}&type=1&page=1">参数列表</a>
                                            </button>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="cell">
                                            <input style="outline: none" type="button" onclick="updateList(${p.id})"
                                                   class="btn btn-info test" value="编辑"/>
                                            <input style="outline: none" type="button"
                                                   class="btn btn-danger" onclick="del(${p.id})" value="删除"/>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>


                        <form action="" method="post" class="form-group">
                            <nav aria-label="..." style="text-align: left">
                                <ul class="pagination">
                                    <li class="disabled">
                                        <a href="#" aria-label="Next">
                                            <span aria-hidden="true">共${productAttributeList2.total}条</span></a>
                                    </li>
                                    <li style="float: left">
                                        <select onchange="changes()" name="pageSizeS" class="selectC"
                                                style="border-left: none;border-right: none;height: 34px;border-top: 1px solid rgb(221,221,221);border-bottom: 1px solid rgb(221,221,221)">
                                            <option value="5" ${productAttributeList2.pageSize==null?"selected":""}>
                                                &nbsp;5条/页
                                            </option>
                                            <option value="10" ${productAttributeList2.pageSize==10?"selected":""}>
                                                10条/页
                                            </option>
                                            <option value="15" ${productAttributeList2.pageSize==15?"selected":""}>
                                                15条/页
                                            </option>
                                            <option value="20" ${productAttributeList2.pageSize==20?"selected":""}>
                                                20条/页
                                            </option>
                                        </select>
                                    </li>
                                    <li class="${productAttributeList2.pageNum==1?'disabled':''}">
                                        <a style="outline: none"
                                           href="${pageContext.request.contextPath}/goods/productType?page=${productAttributeList2.pageNum>1?productAttributeList2.pageNum-1:1}&pageSize=${productAttributeList2.pageSize}"
                                           aria-label="Next">
                                            <span aria-hidden="true">上一页</span></a>
                                    </li>
                                    <c:forEach begin="1" step="1" end="${productAttributeList2.pages}" var="i">
                                        <li class="${productAttributeList2.pageNum==i?'active':''}">
                                            <a style="outline: none"
                                               href="${pageContext.request.contextPath}/goods/productType?page=${i}&&pageSize=${productAttributeList2.pageSize}">
                                                    ${i} <span class="sr-only">(current)</span>
                                            </a>
                                        </li>
                                    </c:forEach>
                                    <li class="${productAttributeList2.pageNum>=productAttributeList2.pages?'disabled':''}">
                                        <a style="outline: none" id="next"
                                           href="${pageContext.request.contextPath}/goods/productType?page=${productAttributeList2.pageNum<productAttributeList2.pages?productAttributeList2.pageNum+1:productAttributeList2.pages}&pageSize=${productAttributeList2.pageSize}"
                                           aria-label="Next">
                                            <span aria-hidden="true">下一页</span></a>
                                    </li>
                                    <li style="float: left;">
                                        <span style="height: 34px">前往<input class="pageSize2" onchange="changeIn()"
                                                                            style="text-align: center;width: 30px;border: 1px solid rgb(221,221,221);outline: none"/>页</span>
                                    </li>
                                </ul>
                            </nav>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <jsp:include page="../inc/footer.jsp"/>


    <script>
        function addList() {
            layer.open({
                title: ["添加类型", "font-size: 22px;font-weight: bold;"],
                type: 1,
                area: ["400px", "200px"],
                content: $('#t')
            });
        }

        function updateList(id) {
            $.post("${pageContext.request.contextPath}/goods/updateType", {id}, function (response) {
                $('#i').val(response.id);
                $('#name').val(response.name);
                layer.open({
                    id: id,
                    type: 1,
                    closeBtn: 1,
                    title: ["修改类型编号:" + id, "font-size: 22px;font-weight: bold;"],
                    area: ["400px", "250px"],
                    content: $('#u')
                });
            })


        }

        function del(id) {
            $.post("${pageContext.request.contextPath}/goods/del", {id}, function (response) {
                $('#num').val(response.id);
                layer.open({
                    id: id,
                    title: ["类型编号:" + id + " 提示！", "font-size: 22px;font-weight: bold;"],
                    type: 1,
                    area: ["400px", "200px"],
                    content: $('#d')
                });
            })
        }

        function changes() {
            console.info($(".selectC").val());
            location.href = "${pageContext.request.contextPath}/goods/productType?page=1" + "&pageSize=" + $(".selectC").val();
        }

        function changeIn() {
            console.info($(".pageSize2").val());
            location.href = "${pageContext.request.contextPath}/goods/productType?page=" + $(".pageSize2").val() + "&pageSize=" + ${productAttributeList2.pageSize};
        }
    </script>

    <!--Begin core plugin -->
    <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/plugins/moment/moment.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/jquery.slimscroll.js "></script>
    <script src="${pageContext.request.contextPath}/assets/js/jquery.nicescroll.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/functions.js"></script>
    <!-- End core plugin -->

    <!--Begin Page Level Plugin-->
    <script src="${pageContext.request.contextPath}/assets/plugins/morris-chart/morris.js"></script>
    <script src="${pageContext.request.contextPath}/assets/plugins/morris-chart/raphael-min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/plugins/jquery-sparkline/jquery.charts-sparkline.js"></script>
    <script src="${pageContext.request.contextPath}/assets/pages/dashboard.js"></script>
    <script src="${pageContext.request.contextPath}/assets/layui/layui.js"></script>
</body>
<div id="t" style="display: none;">
    <form class="layui-form" id="add-form" action="${pageContext.request.contextPath}/goods/saveTypeAdd" method="post">
        <br>
        <br>
        <p class="layui-form-item center" style="text-indent: 20px">
            <span style="color: red">*</span><span style="font-size: 25px;">添加类名&emsp;</span>
            <input required type="text" name="name"
                   style="text-align: center;width: 200px;border: 1px solid rgb(221,221,221);outline: none;font-size: 25px"
                   autocomplete="off">
        </p>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 150px;outline: none">
                <input style="height: 40px;border: 1px solid rgb(221,221,221)" class="layui-btn" type="submit"/>
                &emsp;&emsp;
                <button style="border: none;height: 39px;width: 65px;line-height: 100%;;outline: none"><a
                        href="${pageContext.request.contextPath}/goods/productType">取消</a></button>
            </div>
        </div>
    </form>
</div>
<div id="u" style="display: none;">
    <form class="layui-form" id="update-form" action="${pageContext.request.contextPath}/goods/updateProduct"
          method="post">
        <br>
        <p class="layui-form-item center" style="text-indent: 20px">
            <span style="color: red">&nbsp;&nbsp;</span><span style="font-size: 20px;">类名编号&emsp;</span>
            <input type="text" readonly id="i" name="i"
                   style="outline: none;border:solid 1px rgb(221,221,221);text-align: center;width: 200px;font-size: 20px">
        </p>
        <p class="layui-form-item center" style="text-indent: 20px">
            <span style="color: red">*</span><span style="font-size: 20px;">修改类名&emsp;</span>
            <input id="name" name="name" required type="text"
                   style=";outline: none;border:solid 1px rgb(221,221,221);text-align: center;width: 200px;font-size: 20px"
                   autocomplete="off" value="">
        </p>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 150px">
                <input style="height: 40px;outline: none" class="layui-btn" type="submit"/>
                &emsp;&emsp;
                <button style="border: none;height: 39px;width: 65px;line-height: 100%;outline: none"><a
                        href="${pageContext.request.contextPath}/goods/productType">取消</a></button>
            </div>
        </div>
    </form>
</div>
<div id="d" style="display: none;">
    <form class="layui-form" id="del-form" action="${pageContext.request.contextPath}/goods/delProduct"
          method="post">
        <br>
        <p class="layui-form-item center" style="text-indent: 20px">
            <span style="color: red">*</span><span style="font-weight: bold;font-size: 20px;">确定要删除类型</span><input
                style="width: 50px;outline: none;border: 1px solid rgb(221,221,221);text-align: center" id="num"
                name="id" readonly><span style="font-weight: bold;font-size: 20px;">吗？</span>
        </p>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 150px">
                <input style="height: 40px;outline: none" class="layui-btn" type="submit" value="确定"/>
                &emsp;&emsp;
                <button style="outline: none;border: none;height: 39px;width: 65px;line-height: 100%;outline: none;padding-bottom: 4px">
                    <a
                            href="${pageContext.request.contextPath}/goods/productType">取消</a></button>
            </div>
        </div>
    </form>
</div>
</html>
